package com.jtny.nytb.config.datafactor.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.jtny.component.entity.PageData;
import com.jtny.component.exception.ServiceException;
import com.jtny.component.util.BeanUtils;
import com.jtny.nytb.config.datafactor.dto.*;
import com.jtny.nytb.dataparam.domain.ConfigDataParamManagementDO;
import com.jtny.nytb.dataparam.vo.DevicePageQueryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.rmi.ServerException;
import java.util.List;
import java.util.Map;

/**
 * 规则管理配置DAO接口
 *
 * @author 智慧能源中心 - 刘琦
 * @package com.jtny.nytb.config.datafactor.service
 * @fileName ConfigDataParamManagementService .java
 * @createTime 2023/9/6 9:19
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */


public interface ConfigDataParamManagementService {




    @ApiOperation(("通过id获取参量管理数据"))
    @ApiImplicitParam(name = "id", value = "通过id获取参量管理数据", required = true, paramType = "path")
    @ApiOperationSupport(order = 3)
    @PostMapping("/queryById/{id}")
    ConfigDataParamManagementDTO queryById(@PathVariable("id") Long id);

    public List<ConfigDataParamManagementDTO> queryByName(String name);

    /**
     * 更新数据参量管理接口
     *
     * @param configDataParamManagementDTO
     * @return
     */
    @ApiOperation("更新数据参量管理接口")
    @ApiImplicitParam(name = "configDataParamManagementDTO", value = "更新数据参量管理接口", required = true,
            paramType = "query", dataType = "ConfigDataParamManagementDTO")
    @ApiOperationSupport(order = 4)
    @PostMapping("/update")
    ConfigDataParamManagementDTO update(@RequestBody ConfigDataParamManagementDTO configDataParamManagementDTO) throws ServiceException;


    @ApiOperation(("通过id删除"))
    @ApiImplicitParam(name = "id", value = "通过id删除", required = true, paramType = "query")
    @ApiOperationSupport(order = 6)
    @PostMapping("deleteById/{id}")
    ConfigDataParamManagementDTO deleteById(@PathVariable("id") Long id);

    public ConfigDataParamManagementDTO save(ConfigDataParamManagementDTO configDataParamManagementDTO) throws ServiceException;

    public PageData<ConfigDataParamManagementDTO> queryPage(ConfigDataParamManagementPageDTO paramManagementPageDTO);
    /**
     * 按 ID 列表删除
     *
     * @param ids IDS
     */
    @ApiOperation(("通过id列表删除"))
    @ApiImplicitParam(name = "ids", value = "通过id列表删除", required = true, paramType = "query")
    @ApiOperationSupport(order = 6)
    @DeleteMapping("deleteByIdList/{ids}")
    void deleteByIdList(@PathVariable("ids") List<Long> ids);







    /**
     * 地图代码和 ID 保存批次
     *
     * @param managementDTOList 管理 dtolist
     * @return {@link Map}<{@link String}, {@link Long}>
     */
    @PostMapping("mapCodeAndIdSaveBatch")
    Map<String, Long> mapCodeAndIdSaveBatch(@RequestBody List<ConfigDataParamManagementDTO> managementDTOList);

    public void importParamAndAlgorit(Map<String, List<?>> importData);
    public List<ConfigDataParamManagementDTO> downloadManagement();


//    @ApiOperation(("通过标签id列表查询参量"))
//    @ApiImplicitParam(name = "dataParamManagementQueryDTO", value = "查询参量过滤条件DTO对象", required = true, paramType = "query")
//    @ApiOperationSupport(order = 11)
//    @PostMapping("queryParamByLabelIdList")
//    List<ConfigDataParamManagementDTO> queryParamByLabelIdList(@RequestBody DataParamManagementQueryDTO dataParamManagementQueryDTO);


//    @ApiOperation("通过设备编码和设备id删除参量")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "equipmentCode", value = "设备编码", required = true, paramType = "path"),
//            @ApiImplicitParam(name = "equipmentId", value = "设备id", required = true, paramType = "path")
//    })
//    @ApiOperationSupport(order = 12)
//    @DeleteMapping("/deleteByEquipmentCodeAndId/{equipmentCode}/{equipmentId}")
//    Boolean deleteByEquipmentCodeAndId(@PathVariable("equipmentCode") String equipmentCode,
//                                       @PathVariable("equipmentId") Long equipmentId);
//
//    /**
//     * 通过设备编码查询参量
//     *
//     * @param equipmentCode 设备编码
//     * @return {@link List}<{@link ConfigDataParamManagementDTO}>
//     */
//    @ApiOperation("通过设备编码查询参量")
//    @ApiImplicitParam(name = "equipmentCode", value = "通过设备编码查询参量", required = true,
//            paramType = "path")
//    @ApiOperationSupport(order = 12)
//    @GetMapping("/listByEquipmentCode/{equipmentCode}")
//    List<ConfigDataParamManagementDTO> listByEquipmentCode(@PathVariable("equipmentCode") String equipmentCode);

    /**
     * 查询参量数量
     *
     * @return {@link Long}
     */
    @GetMapping("/count")
    Long countAll();

    /**
     * 列表切割
     *
     * @param offset 抵消
     * @param limit  限制
     * @return {@link List}<{@link ConfigDataParamManagementDTO}>
     */
    @GetMapping("/listCut/{offset}/{limit}")
    List<ConfigDataParamManagementDTO> listCut(@PathVariable("offset") Long offset, @PathVariable("limit") Long limit);

    /**
     * 通过时间查询参量
     *
     * @param time 开始时间
     * @return {@link List}<{@link ConfigDataParamManagementDTO}>
     */
    @ApiOperation("通过时间查询参量")
    @ApiImplicitParam(name = "time", value = "通过时间查询参量", required = true,
            paramType = "path")
    @ApiOperationSupport(order = 13)
    @GetMapping("/listByCreateTime/{time}")
    List<ConfigDataParamManagementDTO> listByCreateTime(@PathVariable("time") Long time);

    @ApiOperation("通过时间查询参量")
    @ApiImplicitParam(name = "time", value = "通过时间查询参量", required = true,
            paramType = "path")
    @ApiOperationSupport(order = 14)
    @GetMapping("/listByUpdateTime/{time}")
    List<ConfigDataParamManagementDTO> listByUpdateTime(@PathVariable("time") Long time);

    /**
     * 按 ID 列出
     *
     * @param dataParamIds 数据参数 ID
     * @return {@link List}<{@link ConfigDataParamManagementDTO}>
     */
    @ApiOperation("获取列表")
    @ApiOperationSupport(order = 15)
    @GetMapping("/listByIds/{dataParamIds}")
    List<ConfigDataParamManagementDTO> listByIds(@PathVariable("dataParamIds") List<Long> dataParamIds);

    /**
     * 按 ID 列出
     *
     * @param dataParamIds 数据参数 ID
     * @return {@link List}<{@link ConfigDataParamManagementDTO}>
     */
    @ApiOperation("获取列表")
    @ApiOperationSupport(order = 15)
    @GetMapping("/mapByIds/{dataParamIds}")
    Map<Long, ConfigDataParamManagementDTO> mapByIds(@PathVariable("dataParamIds") List<Long> dataParamIds);



    /**
     * 通过code获取参量列表
     *
     * @param codes 参量code
     * @return {@link List}<{@link ConfigDataParamManagementDTO}>
     */
    @ApiOperation("获取列表")
    @ApiOperationSupport(order = 16)
//    @GetMapping("/listByCodes/{codes}")
    @PostMapping("/listByCodes")
    List<ConfigDataParamManagementDTO> listByCodes(@RequestBody List<String> codes);

    @ApiOperation("获取参量列表")
    @ApiOperationSupport(order = 17)
    @PostMapping("/listByParams")
    List<ConfigDataParamManagementDTO> listByParams(@RequestBody DataParamQueryDTO dataParamQueryDTO);


    /**
     * @param pevicePageQueryVO
     * @return
     */
    @ApiOperation(("通过参数查询参量"))
    @ApiImplicitParam(name = "pevicePageQueryDTO", value = "查询参量过滤条件DTO对象", required = true, paramType = "query")
    @ApiOperationSupport(order = 19)
    @PostMapping("/queryParamsByParam")
    List<Long> queryParamsByParam(@RequestBody DevicePageQueryVO pevicePageQueryVO);

    /**
     * @param paramIds
     * @return
     */
    @ApiOperation("通过参量id查询数据")
    @ApiImplicitParam(name = "pevicePageQuery", value = "查询参量过滤条件DTO对象", required = true, paramType = "query")
    @ApiOperationSupport(order = 19)
    @PostMapping("/queryDataByParamIds")
    List<DeviceParamDTO> queryDataByParamIds(@RequestBody List<Long> paramIds);

    /**
     * 通过
     *
     * @param DataParamIds
     * @param factorName
     * @return
     */
    @ApiOperation("通过参量id和名称查询数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "DataParamIds", value = "参量id列表", required = true, paramType = "query"),
            @ApiImplicitParam(name = "factorName", value = "参量名称", required = true, paramType = "query")
    })
    @ApiOperationSupport(order = 20)
    @PostMapping("/queryDataByParamIdsAndName")
    List<ConfigDataParamManagementDTO> queryDataByParamIdsAndName(@RequestBody List<Long> DataParamIds, @RequestParam(value = "factorName", required = false) String factorName);

    @ApiOperation("通过设备和参量信息查询数据")
    @ApiImplicitParam(name = "pageDeviceDataParamQuery", value = "对象", required = true, paramType = "query")
    @ApiOperationSupport(order = 21)
    @PostMapping("/getDeaviceAndDataParams")
    List<DeviceDataParamQueryDTO> getDeaviceAndDataParams(@RequestBody PageDeviceDataParamQueryDTO pageDeviceDataParamQuery);


    @PostMapping("/updateDataParamName/{equipmentName}")
    void updateDataParamName(@PathVariable("equipmentName") String equipmentName, @RequestBody List<Long> dataParamIdList);

    /**
     * 通过参量code查询参量名称
     * @param code
     * @return
     */
    @ApiOperation("通过参量code查询参量名称")
    @ApiImplicitParam(name = "code", value = "参量编码", required = true, paramType = "query")
    @ApiOperationSupport(order = 22)
    @PostMapping("/getParamNameByCode")
    ConfigDataParamManagementDTO getParamNameByCode(@RequestBody String code);




    /**
     * 更新状态
     *
     * @param status          地位
     * @param dataParamIdList 数据参数 ID 列表
     */
    @ApiOperation("更新参量状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status", value = "参量状态", required = true, paramType = "query"),
            @ApiImplicitParam(name = "dataParamIdList", value = "参量id列表", required = true, paramType = "query")
    })
    @ApiOperationSupport(order = 23)
    @PostMapping("/updateStatus/{status}")
    void updateStatus(@PathVariable("status") Integer status, @RequestBody List<Long> dataParamIdList);
}
